package com.zr.storehouse.service.impl;

import com.zr.storehouse.mapper.StoreHouseMapper;
import com.zr.storehouse.model.vo.WarehouseSelectVo;
import com.zr.storehouse.model.vo.warehouseSelectResultVo;
import com.zr.storehouse.service.StoreHouseService;
import com.zr.util.AllRecords;
import com.zr.util.ResultVO;
import com.zr.util.ResultVOBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2019/1/11.
 */
@Service
public class StoreHouseServiceImpl implements StoreHouseService {

    @Autowired
    private StoreHouseMapper storeHouseMapper;
    @Override
    public ResultVO<AllRecords> queryStoreHouse(WarehouseSelectVo warehouseSelectVo) {

        int count = storeHouseMapper.queryCount(warehouseSelectVo);
        List<warehouseSelectResultVo> warehouseSelectResultVoList = storeHouseMapper.queryPage(warehouseSelectVo);
        AllRecords allRecords = new AllRecords();
        allRecords.setDataList(warehouseSelectResultVoList);
        allRecords.setPageIndex(warehouseSelectVo.getPageIndex());
        allRecords.setPageSize(warehouseSelectVo.getPageSize());
        allRecords.setTotalNumber(count);
        allRecords.resetTotalNumber(count);
        System.out.println(allRecords);
        return ResultVOBuilder.success(allRecords);
    }
}
